//
//  MyTabBarViewController.swift
//  GroupApp
//
//  Created by 语安 on 16/8/15.
//  Copyright © 2016年 thls.com. All rights reserved.
//

import UIKit

class MyTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let homeVC = HomeViewController()
        let homeNav = UINavigationController(rootViewController: homeVC)
        
        let hotVC = HotViewController()
        let hotNav = UINavigationController(rootViewController: hotVC)
        
        let myVC = MyViewController()
        let myNav = UINavigationController(rootViewController: myVC)
        
        let searchVC = SearchViewController()
        let searchNav = UINavigationController(rootViewController: searchVC)
        
        let navArray = [homeNav, hotNav, searchNav, myNav]
        
        self.viewControllers = navArray
        
        //标题
        let titleArray = ["首页","热门","发现","我的"]
        let unselectedImageArray = ["","","",""]
        let selectedImageArray = ["","","",""]
        
        //设置tabBar
        for i in 0 ..< navArray.count {
            let nav = navArray[i]
            nav.tabBarItem.title = titleArray[i]
            let unselectedImage = UIImage(named: unselectedImageArray[i])
            nav.tabBarItem.image = unselectedImage?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
            let selectedImage = UIImage(named: selectedImageArray[i])
            nav.tabBarItem.selectedImage = selectedImage?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
            
        }
        
        UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orangeColor()], forState: UIControlState.Selected)
    }

    
}
